﻿using Blog.Core.Common;
using Blog.Core.Model.Seed;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Blog.Core.Extensions
{
    public static class DbSetup
    {
        public static void AddDbSetup(this IServiceCollection services)
        {
            if (services == null) throw new ArgumentNullException(nameof(services));

            services.AddScoped<DBSeed>();
            services.AddScoped<MyContext>((s) =>
            {
                MyContext.Init(BaseDBConfig.ConnectionString, SqlSugar.DbType.MySql);
                return MyContext.GetDbContext();
            });
        }
    }
}
